<template>
  <div class="app-container">
    <div class="filter-container default-box">
      <span>订单编号：</span>
      <el-input v-model="listQuery.title" placeholder="请输入订单编号" style="width: 240px;" class="filter-item" />
      <span style="padding-left: 100px;">福利产品：</span>
      <el-input v-model="listQuery.title" placeholder="请输入福利产品" style="width: 240px;" class="filter-item" />
      <span style="padding-left: 100px;">用户：</span>
      <el-input v-model="listQuery.title" placeholder="请输入用户" style="width: 240px;" class="filter-item" />
      <span style="padding-left: 100px;">状态：</span>
      <el-select v-model="statusvalue" placeholder="请选择">
        <el-option v-for="item in statusoptions" :key="item.value" :label="item.label" :value="item.value" />
      </el-select>
      <el-button class="filter-item" type="primary" icon="el-icon-search" style="margin-left:50px" round>
        查询
      </el-button>
      <el-button class="filter-item" icon="el-icon-refresh-right" round>
        重置
      </el-button>
    </div>
    <div class="default-box">
      <el-table
        :key="tableKey"
        v-loading="listLoading"
        :data="list"
        fit
        highlight-current-row
        style="width: 100%;"
      >
        <el-table-column label="订单编号" width="180">
          <template>
            <span>2023032018524767027</span>
          </template>
        </el-table-column>
        <el-table-column label="福利商品" width="200" show-overflow-tooltip>
          <template>
            <span>测试04测试04测试04测试04测试04测试04测试04测试04</span>
          </template>
        </el-table-column>
        <el-table-column label="用户" width="150">
          <template>
            <span> CCA(<span :style="{color:$store.state.settings.theme}">15820998599</span>)</span>
          </template>
        </el-table-column>
        <el-table-column label="购买票数" width="150">
          <template>
            <span>
              10
            </span>
          </template>
        </el-table-column>
        <el-table-column label="中奖票号" width="200">
          <template>
            <span>
              e9R48R9EzJ3EqABh
            </span>
          </template>
        </el-table-column>
        <el-table-column label="下单时间" width="200">
          <template>
            <span>
              2023-03-20 18:52:47
            </span>
          </template>
        </el-table-column>
        <el-table-column label="快递单号" width="220">
          <template>
            <span>
              2064556124556244536655
            </span>
          </template>
        </el-table-column>
        <el-table-column label="发货时间" width="200">
          <template>
            <span>
              2023-03-20 18:52:47
            </span>
          </template>
        </el-table-column>
        <el-table-column label="确认时间" width="200">
          <template>
            <span>
              2023-03-20 18:52:47
            </span>
          </template>
        </el-table-column>
        <el-table-column label="状态" width="150">
          <template>
            <span class="warning-color">已完成</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="200" class-name="small-padding fixed-width">
          <template>
            <el-button type="primary" @click="ticketDialog=true">票号</el-button>
            <el-button type="success" @click="delivergoodsDialog=true">发货</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
    </div>
    <!--  票号对话框 -->
    <el-dialog
      title="票号"
      :visible.sync="ticketDialog"
      width="80%"
      custom-class="operate-dialog main-bagcolor"
      top="5vh"
      center
    >
      <TicketNumber />
    </el-dialog>
    <!--  发货对话框 -->
    <el-dialog
      title="发货"
      :visible.sync="delivergoodsDialog"
      width="80%"
      custom-class="operate-dialog main-bagcolor"
      top="30vh"
      center
    >
      <DeliverGoods />
    </el-dialog>
  </div>
</template>

<script>
import DeliverGoods from './components/deliver-goods'
import TicketNumber from './components/ticket-number'
import { fetchList } from '@/api/article'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
export default {
  name: 'Adminrole',
  components: { Pagination, DeliverGoods, TicketNumber },
  data() {
    return {
      tableKey: 0,
      list: null,
      total: 0,
      listLoading: true,
      listQuery: {
        page: 1,
        limit: 10,
        importance: undefined,
        title: undefined,
        type: undefined,
        sort: '+id'
      },
      statusoptions: [{ // 状态选择项组
        value: '',
        label: '不限'
      }, {
        value: '待开奖',
        label: '待开奖'
      }, {
        value: '待发货',
        label: '待发货'
      }, {
        value: '已发货',
        label: '已发货'
      }, {
        value: '已完成',
        label: '已完成'
      }],
      statusvalue: '', // 状态的类型
      ticketDialog: false, // 是否展示票号对话框
      delivergoodsDialog: false // 是否展示发货对话框
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.listLoading = true
      fetchList(this.listQuery).then(response => {
        this.list = response.data.items
        this.total = response.data.total
        setTimeout(() => {
          this.listLoading = false
        }, 1.5 * 1000)
      })
    }
  }
}
</script>
<style scoped>
  [class^=el-icon-], [class*=" el-icon-"]{
    font-size: 16px;
  }
  .small-padding i{
    margin-right: 12px;
  }
  .small-padding i:last-child{
    margin-right: 0px;
  }
  ::v-deep .filter-container .el-input--medium .el-input__inner{
    width: 240px;
  }
</style>
